#ifndef UTILDEFS_H
#define UTILDEFS_H
#include "GUIConsole.h"

#define WIDEN( w ) WIDEN2( w )
#define WIDEN2( w )	L ##w

#define INFO_OUT( text ) OutputDebugString( L"(INFO) : " WIDEN( __FUNCTION__ ) L"() - " text L"\n" )
#define ERR_OUT( text ) OutputDebugString( L"(ERROR) : " WIDEN( __FUNCTION__ ) L"() - " text L"\n" )
#define WARN_OUT( text ) OutputDebugString( L"(WARNING) : " WIDEN( __FUNCTION__ ) L"() - " text L"\n" )

#ifndef SAFE_CLOSEFILE
#define SAFE_CLOSEFILE(p)       { if (p) { fclose (p);     (p)=NULL; } }
#endif

#ifndef NEW_CHAR_ARRAY
#define NEW_CHAR_ARRAY(p,iSize)       { if (!p) {  p = new char[iSize];  ZeroMemory(p,iSize); } }
#endif

#ifndef OUTPUTERRORINFO
#define OUTPUTERRORINFO    {char tmp[MAX_PATH]; sprintf_s(tmp, "Error:%s(%d)-%s\n",__FILE__,__LINE__,__FUNCTION__); OutputConsoleText(tmp,PRINT_ERROR);}
#endif

#ifndef OUTPUTIMPORTANTINFO
#define OUTPUTIMPORTANTINFO(str)    {OutputConsoleText(str,PRINT_INFO);}
#endif

#endif